﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;
using VO;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace DAL
{
    public class NhanVienDAL:ketnoi
    {
        public bool _NhanVien_them(VO.NhanVienVO data)
        {
            
        
                using (SqlCommand dbCmd = new SqlCommand("nhanvien_them", GetConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.Parameters.Add(new SqlParameter("@manv", data.manv));
                    dbCmd.Parameters.Add(new SqlParameter("@tennv", data.tennv));
                    dbCmd.Parameters.Add(new SqlParameter("@diachi", data.diachi));
                    dbCmd.ExecuteNonQuery();
                }
           
         
            return true;

        }

        public bool _NhanVien_xem(VO.NhanVienVO data)
        {
            using (SqlCommand dbCmd = new SqlCommand("nhanvien_xem", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@manv", data.manv));
                dbCmd.Parameters.Add(new SqlParameter("@tennv", data.tennv));
                dbCmd.Parameters.Add(new SqlParameter("@diachi", data.diachi));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }

        public bool _NhanVien_sua(VO.NhanVienVO data)
        {
            using (SqlCommand dbCmd = new SqlCommand("nhanvien_sua", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@manv", data.manv));
                dbCmd.Parameters.Add(new SqlParameter("@tennv", data.tennv));
                dbCmd.Parameters.Add(new SqlParameter("@diachi", data.diachi));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }
        public bool _NhanVien_xoa(string MaNV)
        {
            using (SqlCommand dbCmd = new SqlCommand("nhanvien_xoa", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@manv",MaNV ));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }

        public bool layDS(VO.NhanVienVO data)
        {
            using (SqlCommand dbCmd = new SqlCommand("", GetConnection()))
            {
                dbCmd.CommandType = CommandType.Text;
                dbCmd.CommandText = "select * from NhanVien";
                dbCmd.Parameters.Add(new SqlParameter("MaNV", data.manv));
                dbCmd.Parameters.Add(new SqlParameter("TenNV", data.tennv));
                dbCmd.Parameters.Add(new SqlParameter("DiaChi", data.diachi));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }


      
    }
}
